import * as types from './mutation-types'
import * as api from '../api/api'
export const catelist = ({dispatch}) => {
  api.GETCATELIST(function (catelist) {
    dispatch(types.GETCATELIST, catelist)
  })
}
export const indexlist = ({dispatch}, option = {}) => {
  api.GETINDEXLIST(function (indexlist) {
    dispatch(types.GETINDEXLIST, indexlist)
  }, option)
}
export const productlist = ({dispatch}, option = {}, callback, isIndex) => {
  api.GETPRODUCTLIST((productlist) => dispatch(types.GETPRODUCTLIST, productlist, callback, isIndex), option)
}
export const advlist = ({dispatch}, option = {}, isbanner) => {
  api.GETINDEXADV((advlist) => dispatch(types.GETINDEXADV, advlist, isbanner), option)
}
export const userinfo = ({dispatch}, userid, callback) => {
  api.GETUSERINFO((info) => dispatch(types.GETUSERINFO, info, callback), userid)
}
export const changecommunity = ({dispatch}, community) => {
  dispatch(types.CHANGECOMMUNITY, community)
}
export const communitys = ({dispatch}, userid) => {
  api.GETCOMMUNITYS((communitys) => dispatch(types.GETCOMMUNITYS, communitys), userid)
}
export const productdetail = ({dispatch}, pid, callback) => {
  api.GETPRODUCTDETAIL((productdetail) => dispatch(types.GETPRODUCTDETAIL, productdetail, callback), pid)
}
export const clearproductdetail = ({dispatch}) => {
  dispatch(types.CLEARPRODUCTDETAIL)
}
export const usercar = ({dispatch}, uid) => {
  api.GETUSERCAR((usercar) => dispatch(types.GETUSERCAR, usercar), uid)
}
export const addpro = ({dispatch}, pro) => {
  dispatch(types.BUYNOW, pro)
}
export const addtocar = ({dispatch}, options, callback) => {
  api.ADDTOCAR((addcar) => dispatch(types.ADDTOCAR, addcar, callback), options)
}
export const coupon = ({dispatch}, options) => {
  api.COUPON((coupon) => dispatch(types.COUPON, coupon), options)
}
export const integral = ({dispatch}, uid, callback) => {
  api.INTEGRAL((integral) => dispatch(types.INTEGRAL, integral, callback), uid)
}
export const integralhistory = ({dispatch}, uid, callback) => {
  api.INTEGRAL_HISTORY((integral) => dispatch(types.INTEGRAL_HISTORY, integral, callback), uid)
}
export const allcount = ({dispatch}, callback) => {
  api.ALLCOUNT((count) => dispatch(types.ALLCOUNT, count, callback))
}
export const lifeserver = ({dispatch}, options, callback) => {
  api.LIFESERVER((life) => dispatch(types.LIFESERVER, life, callback), options)
}
export const activity = ({dispatch}, options, callback) => {
  api.ACTIVITY((activity) => dispatch(types.ACTIVITY, activity, callback), options)
}
export const getEstateList = ({dispatch}, callback) => {
  api.GETESTATE((list) => dispatch(types.GETESTATELIST, list, callback))
}
export const getHouse = ({dispatch}, options, callback) => {
  api.GETHOUSE((list) => dispatch(types.GETHOUSE, list, callback), options)
}
export const getRoom = ({dispatch}, options, callback) => {
  api.GETROOM((list) => dispatch(types.GETROOM, list, options.type, callback), options)
}
export const clearRoom = ({dispatch}) => {
  dispatch('CLEARROOM')
}
export const communityid = ({dispatch}, data) => {
  dispatch('COMMUNITYID', data)
}
export const getReceiver = ({dispatch}, options, callback) => {
  api.RECEIVER((list) => dispatch(types.DELEVERRECEIVE, list, callback), options)
}
export const getReceiverDetail = ({dispatch}, options, callback) => {
  api.RECEIVERDETAIL((info) => dispatch(types.RECEIVEDETAIL, info, callback), options)
}
export const getTimeList = ({dispatch}) => {
  api.GETTIMELIST((info) => dispatch(types.TIMELIST, info))
}
